dim as uinteger MYCOR

MYCOR = rgb(50,100,200)

dim shared as ulongint MMX64_ZERO = &h0000000000000000
dim shared as longint MMX64_MID = &hFFFF01CD01CD01CD
dim shared as longint MMX64_FULL = &hFFFFFFFFFFFFFFFF
dim shared as ulongint MYGAMMA,UBIG
dim as string TST
dim as integer RESULT

MYGAMMA = cint(1.8*256)
MYGAMMA = MYGAMMA or (MYGAMMA shl 16)
MMX64_MID = MYGAMMA or (MYGAMMA shl 32)

asm
  movq MM7,[MMX64_ZERO]
  movq MM6,[MMX64_MID]
  movq MM5,[MMX64_FULL]
  movd MM0,[MYCOR]
  PUNPCKLBW MM0,MM7
  movq MM1,MM0  
  PMULLW MM0,MM6  
  PMULHUW MM1,MM6
  PCMPEQW MM1,MM7
  pxor MM1,MM5
  por MM0,MM1
  psrlw MM0,8
  movq [UBIG],MM0
  packuswb MM0,MM7
  movq [RESULT],MM0  
  emms
end asm

print hex$(MYCOR),, "4 bytes"
TST = hex$(RESULT): TST = string$(16-len(TST),"0")+TST: print TST, "Multiplicado"
TST = hex$(UBIG): TST = string$(16-len(TST),"0")+TST: print TST, "Multiplicado"
sleep